<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<div class="mainBody" style="overflow: auto;width:680px">
    <div class="editBody">
       <?php echo form_open_multipart('app/do_upload/'.$app['app_id']); ?>
       <input type="hidden" name='os' value='<?php echo $cur_os;?>' />
       <input type="hidden" name='group_id' value='<?php echo $cur_group;?>' />
        <div class="bodyTitle" style="">
            <div class="titleIcon editTitle"></div>
            <p class="titleName fontDinproMedium" style="">EDIT APPLICATION</p>
        </div>
        <div class="bodyDiv fontDinpro">
        	<div class="divContent">
        		<p class="fontDinproMedium">OS:</p>
        		<div class="rightContent">
        			<div class="locationGroup listGroupDown listGroup">
		                <a class="btnLeft btnPrimary fontDinpro" data-toggle="dropdown" href="javascript:void(0)" link="">
		                    <?php
		                    	echo $os[$cur_os];
		                    ?>
		                </a>
		                <a class="btnRight btnPrimary" data-toggle="dropdown" href="javascript:void(0)"><span class="caretBottom"></span></a>
		                <ul class="dropDownList fontDinpro">
		                    <?php foreach($os as $k=>$r): ?>
		                        <li>
		                            <a href="javascript:void(0)" class="fontDinpro" link="<?php echo backend_url($language.'/app/upload/'.$app['app_id'].'/'.$k.'/'.$cur_group); ?>">
		                                <?php echo $r; ?>
		                            </a>
		                        </li>
		                    <?php endforeach; ?>
		                </ul>
		            </div>
        		</div>
        	</div>
        	<div class="divContent">
        		<p class="fontDinproMedium">GROUP:</p>
        		<div class="rightContent">
		            <div class="locationGroup listGroupDown listGroup">
		                <a class="btnLeft btnPrimary fontDinpro" data-toggle="dropdown" href="javascript:void(0)" link="">
		                    <?php
		                    	echo $chcode_group_names[$cur_group];
		                    ?>
		                </a>
		                <a class="btnRight btnPrimary" data-toggle="dropdown" href="javascript:void(0)"><span class="caretBottom"></span></a>
		                <ul class="dropDownList fontDinpro">
		                    <?php foreach($chcode_group_names as $k=>$r): ?>
		                        <li>
		                            <a href="javascript:void(0)" class="fontDinpro" link="<?php echo backend_url($language.'/app/upload/'.$app['app_id'].'/'.$cur_os.'/'.$k); ?>">
		                                <?php echo $r; ?>
		                            </a>
		                        </li>
		                    <?php endforeach; ?>
		                </ul>
		            </div>
        		</div>
        	</div>
        </div>
        <div class="bodyDiv fontDinpro">
            <div class="divContent">
                <p class="fontDinproMedium">AppID:</p>
                <div class="rightContent">
                    <label class="fontDinpro"><?php echo $app['app_id'];?></label>
                </div>
            </div>
        </div>
        <div class="bodyDiv fontDinpro">
            <div class="divContent">
                <p class="fontDinproMedium">Name:</p>
                <div class="rightContent">
                    <label class="fontDinpro"><?php echo $app['name'];?></label>
                </div>
            </div>
        </div>
        <div class="bodyDiv fontDinpro">
            <div class="divContent">
                <p class="fontDinproMedium">Icon:</p>
                <div class="rightContent">
                	<img width='80px' src="<?php echo $app['icon']==''?'img/common/defaultIcon.png':$this->config->item('res_domain').$app['icon']; ?>"/>
                </div>
            </div>
        </div>
	
	<?php if(!$app_encrypt):?>
	<div class="bodyDiv fontDinpro">
                <div class="divContent">
                         <p class="fontDinproMedium">Encrypt:</p>
                        <div class="rightContent">
                                <input type="radio" id='encrypt_flag_1' name='encrypt_flag' value='1'>是</input>
                                <input type="radio" id='encrypt_flag_0' checked="checked" name='encrypt_flag' value='0'>否</input>
				<br>
                        	<input type="text"  name="extra_chcode" style="width:300px;height:50px;display:none" id="extra_chcode" align="bottom" value="<?php echo $v['extra_chcode']; ?>" />
			</div>
			<div class="rightContent">
				<label id="extra_chcode_label" style="display:none">[不加密的渠道]</label>
                        </div>
                </div>
        </div>
        <?php endif;?>

 	<?php foreach($app_encrypt as $k => $v):?>
                 <?php if(isset($v['encrypt_flag'])&&$v['encrypt_flag'] == 1):?>
        <div class="bodyDiv fontDinpro">
            <div class="divContent">
                <p class="fontDinproMedium">Encrypt:</p>
                <div class="rightContent">
                        <input type="radio" checked="checked" name='encrypt_flag' value='1'>是</input>
                        <br>
                        <input type="text" name="extra_chcode" style="width:300px;height:50px;" align="bottom" value="<?php if(!empty($v['extra_chcode'])) echo $v['extra_chcode'];else echo "(空)"; ?>" />
		</div>
		<div class="rightContent">
			<label id="extra_chcode_label">[不加密的渠道]</label>
                </div>
            </div>
        </div>
        <?php endif;?>
                 <?php if(!isset($v['encrypt_flag'])||empty($v['encrypt_flag'])||$v['encrypt_flag'] == 0):?>
        <div class="bodyDiv fontDinpro">
                <div class="divContent">
                         <p class="fontDinproMedium">Encrypt:</p>
                        <div class="rightContent">
                                <input type="radio" name='encrypt_flag' value='1'>是</input>
                                <input type="radio" checked="checked" name='encrypt_flag' value='0'>否</input>
                        </div>
                </div>
        </div>
        <?php endif;?>

        <?php endforeach; ?>	

        <div id="messagecontent" class="bodyDiv fontDinpro">
            <div class="divContent" style="margin-bottom:10px">
                <p class="fontDinproMedium">Version:</p>
                <div class="rightContent">
               	<?php
               		foreach($pack_appinfo as $appinfo):?>
							<li><input type="radio" value="<?php echo $appinfo['version'];?>" onchange="changeversion(event);" name="version"><label ><?php echo $appinfo['version'];?></label></li>
               	<?php endforeach;?>
               		<li><input style="color:#000;" id="ver" name="ver" type="text" ></input>&nbsp;</li>
               	</div>
            </div>
        </div>
         <div class="bodyDiv fontDinpro">
         <div class="divContent">
                <p class="fontDinproMedium">上传游戏包:</p>
                <div class="rightContent">
                    <input type="file" id="apk_file" name="apk_file"/>
                    <button class="fontDinpro" type="button" onclick="apk_file.click();">选择文件</button>
                    <label class="fontDinpro" id="u_file_p" name="u_file_p">未选择文件</label>
                </div>
            </div>
       </div>
        <button class="btn submitBtn fontDinproBold" href="javascript:void(0)" type='submit'>SUMBIT</button>
       <?php echo form_close(); ?>
    </div>
</div>

    <script language="JavaScript">
	/* 
	$(document).ready(function(){
		$("#encrypt").click(function(){
			if($("#encrypt").attr('checked')==true){
				document.getElementById("encrypt").value='1';
			}
			else
			{
				document.getElementById("encrypt").value='0';
			}
		});
  	});
	*/
	$(document).ready(function(){
		$("#encrypt_flag_1").click(function(){
				document.getElementById("extra_chcode").style.display='block';
				document.getElementById("extra_chcode_label").style.display='block';
		});
		$("#encrypt_flag_0").click(function(){
                                document.getElementById("extra_chcode").value='';
                                document.getElementById("extra_chcode").style.display='none';
                                document.getElementById("extra_chcode_label").style.display='none';
                });
	});

    function changeversion(event){
		$("#ver").val($(event.currentTarget).val());
    }

    function handleFileSelect(evt) {
        var files = evt.target.files; // FileList object
        // Loop through the FileList and render image files as thumbnails.
        for (var i = 0, f; f = files[i]; i++) {
            var reader = new FileReader();

            // Closure to capture the file information.
            reader.onload = (function(theFile) {
                return function(e) {
                    // Render thumbnail.
                    u_file_p.innerHTML = decodeURIComponent(theFile.name);
                };
            })(f);

            // Read in the image file as a data URL.
            reader.readAsDataURL(f);
        }
    }
    document.getElementById('apk_file').addEventListener('change', handleFileSelect, false);

</script>
